﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;

namespace LifeTree.Core.HttpHandlers
{
    public class StyleSheetHttpHandler : IHttpHandler
    {
        #region IHttpHandler Members

        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/css";
            var filePath = context.Server.MapPath(context.Request.Url.AbsolutePath);
            var content = File.ReadAllText(filePath);
            context.Response.Write(content.Replace("[ApplicationPath]", HttpRuntime.AppDomainAppVirtualPath.Length == 1 ? HttpRuntime.AppDomainAppVirtualPath : HttpRuntime.AppDomainAppVirtualPath + "/"));
            context.Response.End();
        }

        #endregion
    }
}
